package domain
import (
	"errors"
	"sync"
)
type RunningOrder struct  {
	err error//错误详情
	resut bool//上一次数据库查询结果
	content []map[string]interface{}//内容
	mutex sync.RWMutex   // 操作需要用到的读写互斥锁。
//	rmutex sync.Mutex   // 读操作需要用到的互斥锁。
//	fmutex sync.RWMutex // 被用于文件的读写锁。
}

func NewRunningOrder() *RunningOrder{
	return &RunningOrder{
		err:errors.New("I was born just now"),
		resut:false,
		content:make([]map[string]interface{},0),
	}
}

func (dbresult *RunningOrder)Getvalue() (content []map[string]interface{},err error,result bool) {
	dbresult.mutex.RLock()
	defer dbresult.mutex.RUnlock()
	err = dbresult.err
	result = dbresult.resut
	content = dbresult.content
	return
}
func (dbresult *RunningOrder)Setvalue(result bool,err error,content []map[string]interface{})  {
	dbresult.mutex.Lock()
	defer dbresult.mutex.Unlock()
	dbresult.content = content
	dbresult.err = err
	dbresult.resut = result
}

